package com.ctshk.rpc.season.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ctshk.common.enums.IsDeletedCode;
import com.ctshk.common.utils.EntityUtil;
import com.ctshk.rpc.season.dto.SeasonProductChannelOfflineDTO;
import com.ctshk.rpc.season.entity.SeasonProductChannelOffline;
import com.ctshk.rpc.season.mapper.SeasonProductChannelOfflineMapper;
import com.ctshk.rpc.season.service.ISeasonProductChannelOfflineService;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

/**
 * <p>
 * 套票线下自营自定义权限 服务实现类
 * </p>
 *
 * @author 杨林
 * @since 2021-03-15
 */
@DubboService
public class SeasonProductChannelOfflineServiceImpl extends ServiceImpl<SeasonProductChannelOfflineMapper, SeasonProductChannelOffline> implements ISeasonProductChannelOfflineService {

    @Autowired
    private SeasonProductChannelOfflineMapper seasonProductChannelOfflineMapper;

    /* @MethodName: 根据策略 id 获取线下渠道信息
     * @Description: TODO
     * @Param:
     * @Return:
     * @Author: 杨林
     * @Date:2021/3/18 14:52
     **/
    @Override
    public List<SeasonProductChannelOfflineDTO> geOfflineListByStrategyId(Long id) {
        List<SeasonProductChannelOffline> list = seasonProductChannelOfflineMapper.selectList(new QueryWrapper<SeasonProductChannelOffline>().lambda()
                .eq(SeasonProductChannelOffline::getStrategyId, id)
                .eq(SeasonProductChannelOffline::getIsDeleted, IsDeletedCode.NO.getCode())
        );
        return EntityUtil.copyList(list, SeasonProductChannelOfflineDTO.class);
    }

    @Override
    public List<SeasonProductChannelOfflineDTO> geOfflineListByProductIdId(Long id) {
        List<SeasonProductChannelOffline> list = seasonProductChannelOfflineMapper.selectList(new QueryWrapper<SeasonProductChannelOffline>().lambda()
                .eq(SeasonProductChannelOffline::getProductId, id)
                .eq(SeasonProductChannelOffline::getIsDeleted, IsDeletedCode.NO.getCode())
        );
        return EntityUtil.copyList(list, SeasonProductChannelOfflineDTO.class);
    }
}
